package hn.cch.util;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;

public class ExcelUtil
{
    private static Logger logger = LoggerFactory.getLogger(ExcelUtil.class);

    public enum EXCEL{
        XLS(".xls"),
        XLSX(".xlsx");

        public String excel;


        EXCEL(String excel) {
            this.excel = excel;
        }
    }






    public File excelFile(String path, String name, EXCEL type){
        File file = new File(path + name + type.excel);
        return file;
    }

    // public cellFont(){
    //     HSSFFont
    //
    // }

    public boolean readExcel(String path, String name, String type){

        return true;
    }


    public boolean writeExcel(File excelFile, String tableName , String tableDesc, String[][] tableHead, Object[][] tableBody, String tableFoot) throws IOException {

        //区分xls和xlsx
        Workbook workbook;
        Sheet sheet;
        Row row;
        Cell cell;
        Font font;

        CellStyle cellStyle;

        // 工作簿
        HSSFWorkbook hssfWorkbook = new HSSFWorkbook(StreamUtil.toInput(excelFile));
        // 表格
        HSSFSheet hssfSheet = hssfWorkbook.createSheet(excelFile.getName());

        // 表头
        HSSFRow hssfRow = hssfSheet.createRow(0);
        HSSFCell hssfCell = hssfRow.createCell(0);


        // HSSFCellStyle hssfCellStyle = new HSSFCellStyle();
        // hssfCell.setCellStyle();


        return true;

    }



    // XSSF


}
